/*****************************************************************************
    COPYRIGHT (C) 2000, Ken Bertelson <kenbertelson@hotmail.com>


*****************************************************************************/

#if !defined(AFX_GRIDCELLVSAME_H__51055661_F9EE_11D3_B765_00C04F6A7AE6__INCLUDED_)
#define AFX_GRIDCELLVSAME_H__51055661_F9EE_11D3_B765_00C04F6A7AE6__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "GridCell.h"
#include "GridCtrl.h"
#include "DataVSame.h"

class CGridCellVSame : public CGridCellBase  
{
    DECLARE_DYNCREATE(CGridCellVSame)
public:
	CGridCellVSame();
	virtual ~CGridCellVSame();

    void SetDataVSame( CDataVSame* pDataVSame)
        {
            ASSERT( pDataVSame);
            m_pDataVSame = pDataVSame;
        }

// base Attributes
public:
    virtual DWORD    GetState() { return CGridCellBase::GetState() | GVIS_READONLY;  }
    virtual void SetText(LPCTSTR /* szText */) {}   // can't set text -- read-only

    virtual void SetFormat(DWORD nFormat)
        { if( m_pDataVSame) m_pDataVSame->SetFormat(m_iRow, m_iCol, nFormat); }

    virtual void SetImage(int nImage)
        { if( m_pDataVSame) m_pDataVSame->SetImage(m_iRow, m_iCol, nImage); }

    virtual void SetData(LPARAM lParam)
        { if( m_pDataVSame) m_pDataVSame->SetData(m_iRow, m_iCol, lParam); }

    virtual void SetTextClr(COLORREF clr)
        { if( m_pDataVSame) m_pDataVSame->SetTextClr(m_iRow, m_iCol, clr); }

    virtual void SetBackClr(COLORREF clr)
        { if( m_pDataVSame) m_pDataVSame->SetBackClr(m_iRow, m_iCol, clr); }

    virtual void SetFont(const LOGFONT* plf)
        { if( m_pDataVSame) m_pDataVSame->SetFont(m_iRow, m_iCol, plf); }

    virtual void SetMargin( UINT nMargin)
        { if( m_pDataVSame) m_pDataVSame->SetMargin(m_iRow, m_iCol, nMargin); }

    virtual void SetCoords( int nRow, int nCol) { m_iRow = nRow; m_iCol = nCol; }
    virtual CPoint GetCoords() { return CPoint( m_iCol, m_iRow); }

    virtual void SetGrid(CGridCtrl* pGrid)
        { if( m_pDataVSame) m_pDataVSame->SetGrid( pGrid); }

    virtual LPCTSTR  GetText()
        {
            if( m_pDataVSame)
                return m_pDataVSame->GetText(m_iRow, m_iCol);
            return NULL;
        }

    virtual int GetImage()
        {
            if( m_pDataVSame)
                return m_pDataVSame->GetImage(m_iRow, m_iCol);
            return -1;
        }

    virtual LPARAM GetData()
        {
            if( m_pDataVSame)
                return m_pDataVSame->GetData(m_iRow, m_iCol);
            return 0;
        }

    virtual DWORD GetFormat()
        {
            if( m_pDataVSame)
                return m_pDataVSame->GetFormat(m_iRow, m_iCol);
            return 0;
        }

    virtual COLORREF GetTextClr()
        {
            if( m_pDataVSame)
                return m_pDataVSame->GetTextClr(m_iRow, m_iCol);
            return CLR_DEFAULT;
        }

    virtual COLORREF GetBackClr()
        {
            if( m_pDataVSame)
                return m_pDataVSame->GetBackClr(m_iRow, m_iCol);
            return CLR_DEFAULT;
        }

    virtual const LOGFONT* GetFont()
        {
            if( m_pDataVSame)
                return m_pDataVSame->GetFont(m_iRow, m_iCol);
            return NULL;
        }

    virtual UINT GetMargin()
        {
            if( m_pDataVSame)
                return m_pDataVSame->GetMargin(m_iRow, m_iCol);
            return 0;
        }

    virtual CGridCtrl* GetGrid()
        {
            if( m_pDataVSame)
                return m_pDataVSame->GetGrid();
            return NULL;
        }

    virtual BOOL IsEditing() { return FALSE; }

    virtual void operator=(CGridCellBase& cell)
    {
        CGridCellBase::operator=( cell);
    }

protected:
    int      m_iRow;        // Each cell needs to know position
    int      m_iCol;

    CDataVSame* m_pDataVSame;   // contains data common to this instance of the grid as well
                                //  as a reference to the grid, too
};

#endif // !defined(AFX_GRIDCELLVSAME_H__51055661_F9EE_11D3_B765_00C04F6A7AE6__INCLUDED_)
